<?php
/**
 * Created by 荣耀电竞.
 * User: 林子彦 <278805354@qq.com>
 * Date: 2018/7/10 0010
 * Time: 17:12
 */
namespace App\Ordersys\Models;

use App\Base\Models\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;

class OrdersysCircleFileModel extends  BaseModel {
    use SoftDeletes;
    /**
     * 表名
     * @var string
     */
    public $table="ordersys_circle_file";
    /**
     * 时间自动
     * @var bool
     */
    public $timestamps=true;
    /**
     * The name of the "created at" column.
     *
     * @var string
     */
    const CREATED_AT = 'create_time';  //修改添加时间字段
    /**
     * The name of the "updated at" column.
     *
     * @var string
     */
    const UPDATED_AT = 'update_time';

    /**
     * 删除
     */
    const DELETED_AT = 'delete_time';
    /**
     * 模型的日期字段保存格式。
     */
    protected $dateFormat = 'U';
    //是否被领取
    protected $appends = ["is_receive"];


    /**
     * 朋友圈领取记录
     * @return OrdersysFriendsUserslogModel
     */
    public function getOrdersysFriendsUserslogModel(){
        return app()->make(OrdersysFriendsUserslogModel::class);
    }
    /**
     *是否收藏
     * @return bool|int
     */
    public function getIsReceiveAttribute(){
        if(!defined('UID')){
            return false;
        }
        $data=array();
        $data["friends_id"]=$this->id;
        $data["uid"]=UID;
        return $this->getOrdersysFriendsUserslogModel()->newQuery()->where($data)->exists();
    }


}
